<include file="../Public/_header.html" />
<div class="so_main">
		  
		  <!-------- 搜索开始 -------->
		  <div id="search_div" rel='0'>
		  	<div class="page_tit">
		  		搜索代金券[ <a href="javascript:void(0);" onclick="_show_searcharea();">隐藏</a> ]
		  	</div>
				
				<div class="sform">
					<form method="post" action="{:U('/Cashcoupon/index')}" id="searchForm">
						<input id="pno" name="pno" type="hidden" value="1">
						<dl>
							<php>if(!empty($goods_id))$partner_id=getParnterIdByGoodsId($goods_id);</php>
					      	<span>选择商户：</span>
					        <input id="partnerdesc" type="text" value="{:getParnterTitle($partner_id)}"
					        onclick="k_pop_syncSearch('partner_id'
					        													,'partnerdesc'
					        													,'选择商户'
					        													,'{:U('Admin://Partner/getJson')}'
					        													,function(){ $('#goodsdesc').click(); }
					        													,function(){ $('#goodsdesc').val('');$('#goods_id').val(''); })" 
					        readonly >
					        <input name="partner_id" id="partner_id" type="hidden" value="{$partner_id}">

					      	<span>选择商品：</span>
					        <input id="goodsdesc" type="text" value="{:getGoodsTitle($goods_id)}"
					        onclick="k_pop_syncSearch('goods_id'
					        													,'goodsdesc'
					        													,'选择商品'
					        													,'{:U('Admin://Goods/getJson',array('partner_id'=>''))}'+$('#partner_id').val()
					        													,null
					        													,null)" 
					        readonly >
					        <input name="goods_id" id="goods_id" type="hidden" value="{$goods_id}">
					        <span>是否有效：</span>
							&nbsp;&nbsp;
					      	<input name="enable" type="radio" value="all" <eq name="enable" value="all">checked</eq>>全部
					      	&nbsp;&nbsp;&nbsp;
					        <input name="enable" type="radio" value="Y" <eq name="enable" value="Y">checked</eq>>是
					        &nbsp;&nbsp;&nbsp;&nbsp;
					        <input name="enable" type="radio" value="N" <eq name="enable" value="N">checked</eq>>否
							<span>是否取消：</span>
							&nbsp;&nbsp;
					      	<input name="is_canceled" type="radio" value="all" <eq name="is_canceled" value="all">checked</eq>>全部
					      	&nbsp;&nbsp;&nbsp;
					        <input name="is_canceled" type="radio" value="Y" <eq name="is_canceled" value="Y">checked</eq>>是
					        &nbsp;&nbsp;&nbsp;&nbsp;
					        <input name="is_canceled" type="radio" value="N" <eq name="is_canceled" value="N">checked</eq>>否
					    </dl>
					    <dl>
					    	<input type="submit" class="btn_b" value="搜索" />
					    	&nbsp;&nbsp;&nbsp;&nbsp;
					    	<input type="reset" class="btn_b" value="清空" />
					    </dl>
					</form>
					<div class="clear"></div>
			  </div>
		  </div>
		  <!-------- 搜索结束 -------->
		  

  <div class="page_tit">代金券</div>
  <div class="Toolbar_inbox">
  		<a href="javascript:void(0);" class="btn_a" onclick="_show_searcharea();">
			<span>条件搜索</span>
		</a>
    	<a href="javascript:void(0);" class="btn_a" 
    	onclick="ui.confirm(this,'确定删除所选择的代金券，删除成功后将无法恢复，确认继续？');" callback="del();"><span>删除代金券</span></a>
  </div>
  
  <div class="list">
  <table id="goods_list" width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th style="width:30px;">
        <input type="checkbox" id="checkbox_handle" onclick="table_checkAll(this)" value="0">
        <label for="checkbox"></label>
    </th>
    <th class="line_l" style="text-align:center">有效|取消</th>
    <th class="line_l" style="text-align:center">ID</th>
    <th class="line_l" style="text-align:center">名称</th>
    <th class="line_l" style="text-align:center">类型</th>
    <th class="line_l" style="text-align:center">金额</th>
    <th class="line_l" style="text-align:center">总数</th>
    <th class="line_l" style="text-align:center">已用</th>
    <th class="line_l" style="text-align:center">开始时间</th>
    <th class="line_l" style="text-align:center">结束时间</th>
    <th class="line_l" style="text-align:center">相关商户</th>
    <th class="line_l" style="text-align:center">相关商品</th>
    <th class="line_l" style="text-align:center">创建时间</th>
    <th class="line_l" style="text-align:center">操作</th>
  </tr>
  <volist id="vo" name="datapage['data']">
  		<php>$_rule_data = unserialize($vo['rule_data']);</php>
      <tr overstyle='on' id="cashcoupon_{$vo.id}">
        <td><input type="checkbox" name="checkbox" id="checkbox2" onclick="table_checkon(this)" value="{$vo.id}"></td>
        <td style="text-align:center;padding: 6px 0 6px 0px;color:red">
        	{$vo.enable}&nbsp;|&nbsp;{$vo.is_canceled}</td>
        <td>{$vo.id}</td>
 		<td style="text-align:center">{$vo['title']}</td>
 		<td style="text-align:center">{$vo['sort_code']|getCategoryName}</td>
		<td style="text-align:center">{$vo.amount}元</td>		
		<td style="text-align:center">{$vo.total_no}</td>
		<td style="text-align:center">{$vo.used_no}</td>
		<td style="text-align:center">{:paramMillisecond2Date($vo['stime'],'Y-m-d H:i', '未设置' )}</td>
		<td style="text-align:center">{:paramMillisecond2Date($vo['etime'],'Y-m-d H:i', '未设置' )}</td>
		
		<td style="text-align:center">{:getParnterTitle( substr( $_rule_data['partner_id'], 2 ) )}</td>
		<td style="text-align:center">{:getGoodsTitle( substr( $_rule_data['goods_id'], 2 ) )}</td>
		
		<td style="text-align:center">{:paramMillisecond2Date($vo['ctime'],'Y-m-d H:i', '未设置' )}</td>

        <td style="text-align:center">
        	<a href="javascript:void(0);"
        	 	onclick="ui.confirm(this,'确定删除所选择的代金券，删除成功后将无法恢复，确认继续？');" callback="del( '{$vo.id}' );" 
        	 	title="删除代金券！">删除</a>
            <a href="{:U('/Cashcoupon/code',array('cashcoupon_id'=>$vo['id']))}" title="查看代金券码！">券码</a>
        </td>
      </tr>
  </volist>
  </table>

  </div>
  <div class="Toolbar_inbox">
    <div class="page_box">{$datapage['html']}</div>
  </div>
 
</div>

 <div class="clear"></div>

<script>
    //鼠标移动表格效果
    $(document).ready(function(){
    	table_init();
    });
    
    
    
    //删除分类
    function del(aid) {
        aid = aid ? aid : table_getChecked();
        aid = aid.toString();
        if(aid == '') return false;
		
        //提交删除
        $.post("{:U('/Cashcoupon/del')}", {ids:aid}, function(res){
        	alert(res);
	        if(res == '1') {
		        aid = aid.split(',');
		        $.each(aid, function(i,n){
		            $('#cashcoupon_'+n).remove();
		        });
	            ui.success('删除成功');
	        }else {
	        	ui.success('删除失败');
	        }
        });
        
        
    }
</script>

<include file="../Public/_footer.html" />